package app.domain.server.util;

import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;

public class MessageOutBox {
	
	private Queue<String> messageOutBox = new LinkedBlockingQueue<>();
	
	public synchronized boolean add(String str) {
		messageOutBox.add(str);
			notify();
			return true;
	}
	
	public synchronized String remove() {
		while(messageOutBox.isEmpty()) {
			try {
				wait();
			} catch (InterruptedException e) {}
		}
		return messageOutBox.remove();
	}
}
